home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*----------------*
- * CPPLMEN8.C *
- * Menu manager8 *
- *----------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu8,return1;
- extern int colour1,colour2,colour3,colour4,colour5,returning;
- extern unsigned char c0,c1,trashcan[];
-
- /*----------------------*
- * CHOICE DISPLAY HELP8 *
- *----------------------*/
- void choice_display_help8()
- {
- /* We display the help that concerns the line on */
- /* which is the menu cursor (in red). */
- if(menu8==1){
- /* */
- display_help("MENU8 ",75,2,1); restore_help_screen();
- }
- if(menu8==2){
- /* */
- display_help("MENU8 ",76,3,1); restore_help_screen();
- }
- if(menu8==3){
- /* */
- display_help("MENU8 ",77,4,1); restore_help_screen();
- }
- if(menu8==4){
- /* */
- display_help("MENU8 ",78,5,1); restore_help_screen();
- }
- if(menu8==5){
- /* */
- display_help("MENU8 ",79,6,1); restore_help_screen();
- }
- if(menu8==6){
- /* */
- display_help("MENU8 ",80,7,1); restore_help_screen();
- }
- if(menu8==7){
- /* available */
- display_help("MENU8 ",81,8,1); restore_help_screen();
- }
- if(menu8==8){
- /* */
- display_help("MENU8 ",82,9,1); restore_help_screen();
- }
- if(menu8==9){
- /* */
- display_help("MENU8 ",83,10,1); restore_help_screen();
- }
- if(menu8==10){
- /* */
- display_help("MENU8 ",84,11,1); restore_help_screen();
- }
- }
- /*----------------*
- * GET THE MOUSE8 *
- *----------------*/
- int get_the_mouse8()
- {
- /* If we choose with the mouse */
- /* Only available for menu 1 */
- if(ym==1){
- /* We clicked on the first line, certainly */
- /* To change of menu. */
- x=get_the_mouse0();
- menu0=x; return(-2);
- }
- if((xm>54)&&(xm<71)){
- if(ym==3){
- /* */
- menu8=1; return(1);
- }
- if(ym==4){
- /* */
- menu8=2; return(1);
- }
- if(ym==5){
- /* */
- menu8=3; return(1);
- }
- if(ym==6){
- /* */
- menu8=4; return(1);
- }
- if(ym==7){
- /* */
- menu8=5; return(1);
- }
- if(ym==8){
- /* */
- menu8=6; return(1);
- }
- if(ym==9){
- /* */
- menu8=7; return(1);
- }
- if(ym==10){
- /* */
- menu8=8; return(1);
- }
- if(ym==11){
- /* */
- menu8=9; return(1);
- }
- if(ym==12){
- /* */
- menu8=10; return(1);
- }
- }
- /* If we clicked outside the menu zone */
- /* we want to erase the menu and return to menu 0 */
- /* */
- menu0=0; return(-2);
- }
- /*----------------*
- * MENU CHOICE8 *
- *----------------*/
- int menu_choice8()
- {
- returning=wait_for_a_key();
- /* Else we pressed a keyboard key */
- /* Cf CPPLTC2.C for the keyboard test and the returned codes */
- if(returning==-1){
- /* <Esc> we want to go back to menu0 */
- menu0=0; return(-2);
- }
- if(returning==40){
- /* <Enter> execute the command */
- return(1);
- }
- if(returning==100){
- /* We pressed a mouse button */
- m=get_the_mouse8(); return(m);
- }
- /* The key letters depends on the menu */
-
- /* So the below returns need to be modified */
- if(returning==24){
- /* <O> <o> */
- menu8=1; return(1);
- }
- if(returning==23){
- /* <N> <n> */
- menu8=2; return(1);
- }
- if(returning==28){
- /* <S> <s> */
- menu8=3; return(1);
- }
- if(returning==13){
- /* <D> <d> */
- menu8=5; return(1);
- }
- if(returning==27){
- /* <R> <r> */
- menu8=6; return(1);
- }
- if(returning==18){
- /* <I> <i> */
- menu8=7; return(1);
- }
- if(returning==15){
- /* <F> <f> */
- menu8=8; return(1);
- }
- if(returning==26){
- /* <Q> <q> */
- menu8=10; return(1);
- }
- /* For the 2-bytes coded keys, this is the second byte */
- if(returning==59){
- /* Function key <F1> = help */
- return(59);
- }
- if(returning>100){
- /* We pressed Alt + another key to get a menu */
- c1=returning-100; k=get_special_menu00();
- if(k>0) return(-2);
- }
- if((returning==77)||(returning==75)){
- /* Left or Right arrow to change of menu */
- c1=returning; k=get_special_menu00();
- if(k>0) return(-2);
- }
- if(returning==72){
- /* Up arrow */
- if(menu8>1) menu8--;
- else menu8=10;
- return(0);
- }
- if(returning==80){
- /* Down arrow */
- if(menu8<10) menu8++;
- else menu8=1;
- return(0);
- }
- /* Else we return 0 = no choice */
- return(0);
- }
- /*--------------------*
- * DISPLAY MENU LINE8 *
- *--------------------*/
- void display_menu_line8()
- {
- /* First we display the chosen menu0 */
- textattr(colour5);
- gotoxy(57,1); cputs(" Menu8 ");
- /* Same thing for the selected line */
- if(menu8==1){
- gotoxy(55,3); cputs(" ");
- }
- if(menu8==2){
- gotoxy(55,4); cputs(" ");
- }
- if(menu8==3){
- gotoxy(55,5); cputs(" ");
- }
- if(menu8==4){
- gotoxy(55,6); cputs(" ");
- }
- if(menu8==5){
- gotoxy(55,7); cputs(" ");
- }
- if(menu8==6){
- gotoxy(55,8); cputs(" ");
- }
- if(menu8==7){
- gotoxy(55,9); cputs(" ");
- }
- if(menu8==8){
- gotoxy(55,10); cputs(" ");
- }
- if(menu8==9){
- gotoxy(55,11); cputs(" ");
- }
- if(menu8==10){
- gotoxy(55,12); cputs(" ");
- }
- }
- /*----------------------*
- * DISPLAY KEY LETTER 8 *
- *----------------------*/
- void display_key_letter8()
- {
- textattr(116);
- gotoxy(56,3); cputs(" ");
- gotoxy(56,4); cputs(" ");
- gotoxy(56,5); cputs(" ");
- gotoxy(56,6); cputs(" ");
- gotoxy(56,7); cputs(" ");
- gotoxy(56,8); cputs(" ");
- gotoxy(56,9); cputs(" ");
- gotoxy(56,10); cputs(" ");
- gotoxy(56,11); cputs(" ");
- gotoxy(56,12); cputs(" ");
- }
- /*---------------*
- * DISPLAY MENU8 *
- *---------------*/
- void display_menu8()
- {
- /* To avoid the trace of the previous mouse position */
- /* we hide it during the display, */
- /* and show it when the line has been displayed. */
- hide_the_mouse(); textattr(colour2);
- gotoxy(53,2); cputs(" ┌────────────────┐ ");
- gotoxy(53,3); cputs(" │ │ ");
- gotoxy(53,4); cputs(" │ │ ");
- gotoxy(53,5); cputs(" │ │ ");
- gotoxy(53,6); cputs(" │ │ ");
- gotoxy(53,7); cputs(" │ │ ");
- gotoxy(53,8); cputs(" │ │ ");
- gotoxy(53,9); cputs(" │ │ ");
- gotoxy(53,10); cputs(" │ │ ");
- gotoxy(53,11); cputs(" │ │ ");
- gotoxy(53,12); cputs(" │ │ ");
- gotoxy(53,13); cputs(" └────────────────┘ ");
- display_key_letter8(); display_menu_line8();
- show_the_mouse();
- }
- /*----------------*
- * MENU MANAGER 8 *
- *----------------*/
- int menu_manager8()
- {
- restore_screen(); return1=0;
- while(1){
- display_menu8(); return1=menu_choice8();
- if(return1==-2) return(-2);
- if(return1==-1) return(-1);
- if(return1==22) choice_display_help8();
- display_menu8();
- if(return1==1){
- /* We execute the selected function */
- if(menu8==10){
- /* We want to quit the sub-program */
- return(-1);
- }
- if(menu8==1){
- /* */
-
- }
- if(menu8==2){
- /* */
-
- }
- if(menu8==3){
- /* */
-
- }
- if(menu8==4){
- /* */
-
- }
- if(menu8==5){
- /* */
-
- }
- if(menu8==6){
- /* */
-
- }
- if(menu8==7){
- /* */
-
- }
- if(menu8==8){
- /* */
-
- }
- if(menu8==9){
- /* */
-
- }
- }
- }
- }
- /* End of the Module *//*----------------*/
-